import os
import cv2
import json

path = r'/media/xf/97351D9CD3EB251A/Users/Admin/Desktop/imagedata/reflag'
save_path = r'/media/xf/97351D9CD3EB251A/Users/Admin/Desktop/imagedata/reline'
for fname in os.listdir(path):
    try:
            with open(os.path.join(path,fname.strip()), 'r', encoding='utf-8') as f:
                data = json.load(f)
                shape = data["shapes"]
                print(fname)
                print(len(shape) == 0)
                if len(data['shapes']) == 0:
                    continue
                json.dump(data, open(os.path.join(save_path, fname), 'w', encoding='utf-8'), indent=4)
    except:
        continue